package com.ak.server.quartz.controller;

import java.util.Map;

import javax.validation.constraints.NotBlank;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ak.common.controller.BaseController;
import com.ak.common.entity.AKResponse;
import com.ak.common.entity.QueryRequest;
import com.ak.common.utils.AKUtil;
import com.ak.server.quartz.entity.SysJobLog;
import com.ak.server.quartz.service.ISysJobLogService;

import lombok.RequiredArgsConstructor;

/**
 * 调度日志操作处理
 *
 * @author Vean
 */
@RestController
@RequestMapping("jobLog")
@RequiredArgsConstructor
public class SysJobLogController extends BaseController {
   
    private final ISysJobLogService jobLogService;

    @GetMapping
    public AKResponse list(QueryRequest request, SysJobLog jobLog) {
        Map<String, Object> dataTable = AKUtil.getDataTable(jobLogService.selectJobLogList(jobLog, request));
        return new AKResponse().data(dataTable);
    }

    @DeleteMapping("/{ids}")
    public void remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        jobLogService.deleteJobLogByIds(ids);
    }

    @DeleteMapping("/clean")
    public void clean() {
        jobLogService.cleanJobLog();
    }
}
